﻿@model MvcCms.Store.Web.ViewModels.DefaultViewModel
@helper Truncate(string input, int length)
    {
    if (input.Length <= length)
    {
    @input
    }
    else
    {
    @input.Substring(0, length)<text>...</text>
    }
}
<h2>Products</h2>
<table>
    <tr>
        <td>
            @Html.ActionLink("Daily Orders", "DailyStoreOrders")
        </td>
        <td>
            @Html.ActionLink("Price Options", "PriceOptions")
        </td>
    </tr>
    <tr>    
        <td>
            @Html.ActionLink("Create Product", "Create")
        </td>

        <td>
            @Html.ActionLink("Image Manager", "ImageManager")
        </td>
    </tr>
</table>
<br />
<table>
    <tr>
        <th>
            Category
        </th>
        <th>
            Title
        </th>
        <th>
            Price
        </th>
        <th>
        </th>
    </tr>
    @foreach (var item in Model._Products)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Category.Name)
            </td>
            <td>
                @Truncate(item.Title, 25)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Price)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.ProductID }) |
                @Html.ActionLink("Details", "Details", new { id = item.ProductID }) 
            </td>
        </tr>
    }
</table>
